/**
 * WMS通用操作配置常量
 */

import type { WmsActionConfig } from "../types";

/**
 * 常用操作配置预设
 */
export const COMMON_ACTIONS: Record<string, WmsActionConfig> = {
  // 查看详情
  view: {
    type: "view",
    label: "查看",
    buttonType: "info" as const,
    icon: "View",
    text: true,
  },

  // 编辑
  edit: {
    type: "edit",
    label: "编辑",
    buttonType: "primary" as const,
    icon: "Edit",
    text: true,
  },

  // 删除
  delete: {
    type: "delete",
    label: "删除",
    buttonType: "danger" as const,
    icon: "Delete",
    text: true,
    confirm: {
      message: "确定要删除这条记录吗？删除后不可恢复。",
      type: "warning" as const,
    },
  },

  // 启用
  enable: {
    type: "enable",
    label: "启用",
    buttonType: "success" as const,
    icon: "Check",
    text: true,
    show: (row: any) => row?.status === 0,
  },

  // 禁用
  disable: {
    type: "disable",
    label: "禁用",
    buttonType: "warning" as const,
    icon: "Close",
    text: true,
    show: (row: any) => row?.status === 1,
    confirm: {
      message: "确定要禁用这条记录吗？",
      type: "warning" as const,
    },
  },

  // 审核
  approve: {
    type: "approve",
    label: "审核",
    buttonType: "success" as const,
    icon: "CircleCheck",
    text: true,
    show: (row: any) => row?.status === 0,
  },

  // 拒绝
  reject: {
    type: "reject",
    label: "拒绝",
    buttonType: "danger" as const,
    icon: "CircleClose",
    text: true,
    show: (row: any) => row?.status === 0,
    confirm: {
      message: "确定要拒绝这条申请吗？",
      type: "warning" as const,
    },
  },

  // 导出
  export: {
    type: "export",
    label: "导出",
    buttonType: "info" as const,
    icon: "Download",
    text: true,
  },

  // 打印
  print: {
    type: "print",
    label: "打印",
    buttonType: "info" as const,
    icon: "Printer",
    text: true,
  },
};

/**
 * 操作权限映射
 */
export const ACTION_PERMISSIONS: Record<string, string> = {
  view: "view",
  edit: "edit",
  delete: "delete",
  enable: "edit",
  disable: "edit",
  approve: "approve",
  reject: "reject",
  export: "export",
  print: "print",
};
